package server.tests;

import static org.junit.Assert.*;

import java.util.ArrayList;

import messaage.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import server.controller.*;


public class ControllerTests {
	private Controller c;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		c = new Controller();
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testGetRegisterMsg(){
		RegisterMsg regMsg1 = new RegisterMsg("fname", "lname", "email", 'f',"uname", "pw");
		OkMsg ans1 = (OkMsg)this.c.getRegisterMsg(regMsg1);
		assertEquals("user was registered successfully", ans1.getBody());
		RegisterMsg regMsg2 = new RegisterMsg("fname1", "lname1", "email1", 'm', "uname","pw1");
		ErrorMsg ans2 = (ErrorMsg)this.c.getRegisterMsg(regMsg2);
		assertEquals("user with such username exists", ans2.getBody());
	}

	@Test
	public void testGetLoginMsg(){
		RegisterMsg regMsg = new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw");
		this.c.getRegisterMsg(regMsg);
		LoginMsg msg = new LoginMsg("uname", "pw");
		assertEquals(msg.getUsername(), this.c.getLoginMsg(msg).getUsername());
		ErrorMsg error1 = (ErrorMsg)this.c.getLoginMsg(new LoginMsg("uname1", "pw"));
		assertEquals("user is not registered", error1.getBody());
		ErrorMsg error2 = (ErrorMsg)this.c.getLoginMsg(new LoginMsg("uname", "Pw"));
		assertEquals("passwords are not the same", error2.getBody());
	}

	@Test
	public void testGetLogoffMsg(){
		RegisterMsg regMsg = new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw");
		this.c.getRegisterMsg(regMsg);
		LoginMsg msg = new LoginMsg("uname", "pw");
		this.c.getLoginMsg(msg);
		LogoutMsg msg1 = new LogoutMsg("uname");
		this.c.getLogoffMsg(msg1);
		assertEquals(msg.getUsername(), this.c.getLogoffMsg(msg1).getUsername());
		ErrorMsg error1 = (ErrorMsg)this.c.getLogoffMsg(new LogoutMsg("uname1"));
		assertEquals("user is not registered", error1.getBody());
	}

	@Test
	public void testGetRemoveUserMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'm', "uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		OkMsg msg = (OkMsg)this.c.getRemoveUser(new RemoveUserMsg("Masha", "uname"));
		assertTrue(msg.getBody().contains("removed successfully"));
		assertEquals(6, this.c.getStorage().getUsers().size());
		ErrorMsg err1 = (ErrorMsg)this.c.getRemoveUser(new RemoveUserMsg("Masha", "uname2"));
		assertTrue(err1.getBody().contains("this user is not registered"));
		assertEquals(6, this.c.getStorage().getUsers().size());
		ErrorMsg err2 = (ErrorMsg)this.c.getRemoveUser(new RemoveUserMsg("Olgasib", "uname"));
		assertTrue(err2.getBody().contains("the user who removes is not logged in"));
		assertEquals(6, this.c.getStorage().getUsers().size());
		ErrorMsg err3 = (ErrorMsg)this.c.getRemoveUser(new RemoveUserMsg("uname1", "uname"));
		assertTrue(err3.getBody().contains("the user who removes is not a moderator"));
		assertEquals(6, this.c.getStorage().getUsers().size());
		ErrorMsg err4 = (ErrorMsg)this.c.getRemoveUser(new RemoveUserMsg("uname2", "uname"));
		assertTrue(err4.getBody().contains("the user who removes is not registered"));
		assertEquals(6, this.c.getStorage().getUsers().size());
	}

	@Test
	public void testGetAddUserFriendMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'm', "uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("uname1", "pw1"));
		OkMsg msg = (OkMsg)this.c.getAddUserFriendMsg(new AddFriendMsg("uname", "uname1"));
		assertTrue(msg.getBody().contains("was added successfully"));
		ErrorMsg err = (ErrorMsg)(this.c.getAddUserFriendMsg(new AddFriendMsg("uname", "uname1")));
		assertTrue(err.getBody().contains("already exists"));
		assertEquals(1, this.c.getStorage().getUsers().get(5).getFriends().size());
		ErrorMsg err1 = (ErrorMsg)(this.c.getAddUserFriendMsg(new AddFriendMsg("Masha", "uname1")));
		assertTrue(err1.getBody().contains("user is not logged in"));
		ErrorMsg err2 = (ErrorMsg)(this.c.getAddUserFriendMsg(new AddFriendMsg("uname1", "uname1")));
		assertTrue(err2.getBody().contains("cannot add yorself to your friends"));
		ErrorMsg err3 = (ErrorMsg)(this.c.getAddUserFriendMsg(new AddFriendMsg("uname", "uname2")));
		assertTrue(err3.getBody().contains("is not registered"));
		ErrorMsg err4 = (ErrorMsg)(this.c.getAddUserFriendMsg(new AddFriendMsg("uname2", "uname1")));
		assertTrue(err4.getBody().contains("is not registered"));
	}

	@Test
	public void testGetRemoveUserFriendMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'm', "uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("uname1", "pw1"));
		this.c.getAddUserFriendMsg(new AddFriendMsg("uname", "uname1"));
		this.c.getAddUserFriendMsg(new AddFriendMsg("uname", "Alonsgl"));
		OkMsg msg = (OkMsg)this.c.getRemoveUserFriendMsg(new RemoveFriendMsg("uname", "uname1"));
		assertTrue(msg.getBody().contains("was removed successfully"));
		assertEquals(1, this.c.getStorage().getUsers().get(5).getFriends().size());
		ErrorMsg err1 = (ErrorMsg)this.c.getRemoveUserFriendMsg(new RemoveFriendMsg("uname", "uname2"));
		assertTrue(err1.getBody().contains("removing was failed"));
		assertEquals(1, this.c.getStorage().getUsers().get(5).getFriends().size());
		ErrorMsg err2 = (ErrorMsg)this.c.getRemoveUserFriendMsg(new RemoveFriendMsg("uname", "Masha"));
		assertTrue(err2.getBody().contains("removing was failed"));
		assertEquals(1, this.c.getStorage().getUsers().get(5).getFriends().size());
		this.c.getLogoffMsg(new LogoutMsg("uname"));
		ErrorMsg err3 = (ErrorMsg)this.c.getRemoveUserFriendMsg(new RemoveFriendMsg("uname", "AlonSgl"));
		assertTrue(err3.getBody().contains("User who removes must be logged in"));
		assertEquals(1, this.c.getStorage().getUsers().get(5).getFriends().size());
	}

	@Test
	public void testGetAddForumMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f',  "uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getLoginMsg(new LoginMsg("Olgasib", "1234"));
		OkMsg msg = (OkMsg)this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		assertTrue(msg.getBody().contains("was added successfully"));
		assertEquals(1, this.c.getStorage().getForums().getForums().size());
		ErrorMsg err1 = (ErrorMsg)this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		assertTrue(err1.getBody().contains("already exists"));
		assertEquals(1, this.c.getStorage().getForums().getForums().size());
		ErrorMsg err2 = (ErrorMsg)this.c.getAddForumMsg(new AddForumMsg("Olgasib", "something"));
		assertTrue(err2.getBody().contains("already exists"));
		assertEquals(1, this.c.getStorage().getForums().getForums().size());
		ErrorMsg err3 = (ErrorMsg)this.c.getAddForumMsg(new AddForumMsg("Alonsgl", "something"));
		assertTrue(err3.getBody().contains("User who adds forum must be logged in"));
		assertEquals(1, this.c.getStorage().getForums().getForums().size());
		ErrorMsg err4 = (ErrorMsg)this.c.getAddForumMsg(new AddForumMsg("uname", "something"));
		assertTrue(err4.getBody().contains("must be a moderator"));
		assertEquals(1, this.c.getStorage().getForums().getForums().size());
		ErrorMsg err5 = (ErrorMsg)this.c.getAddForumMsg(new AddForumMsg("uname1", "something"));
		assertTrue(err5.getBody().contains("must be registered"));
		assertEquals(1, this.c.getStorage().getForums().getForums().size());
		ErrorMsg err6 = (ErrorMsg)this.c.getAddForumMsg(new AddForumMsg("Masha", ""));
		assertTrue(err6.getBody().contains("subject of forum cannot be empty"));
		assertEquals(1, this.c.getStorage().getForums().getForums().size());
	}

	@Test
	public void testGetCreateThread(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'f', "uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		OkMsg msg = (OkMsg)this.c.getCreateThread(new CreateThreadMsg("uname", "0", "something else", "new something"));
		assertTrue(msg.getBody().contains("thread was added successfully"));
		ErrorMsg err1 = (ErrorMsg)this.c.getCreateThread(new CreateThreadMsg("uname", "0", "something else", "new something else"));
		assertTrue(err1.getBody().contains("already exists"));
		ErrorMsg err2 = (ErrorMsg)this.c.getCreateThread(new CreateThreadMsg("uname1", "0", "something else", "new something else"));
		assertTrue(err2.getBody().contains("must be logged in"));
		ErrorMsg err3 = (ErrorMsg)this.c.getCreateThread(new CreateThreadMsg("uname2", "0", "something else", "new something else"));
		assertTrue(err3.getBody().contains("must be registered"));
		ErrorMsg err4 = (ErrorMsg)this.c.getCreateThread(new CreateThreadMsg("uname1", "0", "", "new something else"));
		assertTrue(err4.getBody().contains("cannot be empty"));
	}

	@Test
	public void testGetAddPostMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'f', "uname1", "pw1"));
		this.c.getRegisterMsg(new RegisterMsg("fname2", "lname2", "email2", 'm', "uname2", "pw2"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		this.c.getCreateThread(new CreateThreadMsg("uname", "0", "something else", "new something"));
		OkMsg msg = (OkMsg)this.c.getAddPostMsg(new AddPostMsg("uname", "0", "0", "answer to something else", "no something else"));
		assertTrue(msg.getBody().contains("post was added successfully"));
		OkMsg msg1 = (OkMsg)this.c.getAddPostMsg(new AddPostMsg("uname1", "0", "0", "answer to something else", "no something else continues"));
		assertTrue(msg1.getBody().contains("post was added successfully"));
		ErrorMsg err2 = (ErrorMsg)this.c.getAddPostMsg(new AddPostMsg("uname2", "0", "0", "answer to something else", "no something else continues"));
		assertTrue(err2.getBody().contains("must be logged in"));
		ErrorMsg err3 = (ErrorMsg)this.c.getAddPostMsg(new AddPostMsg("uname3", "0", "0", "answer to something else", "no something else continues"));
		assertTrue(err3.getBody().contains("must be registered"));
		ErrorMsg err4 = (ErrorMsg)this.c.getAddPostMsg(new AddPostMsg("uname1", "0", "0", "", "no something else continues"));
		assertTrue(err4.getBody().contains("empty"));
	}

	@Test
	public void testGetRemovePostMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'f', "uname1","pw1"));
		this.c.getRegisterMsg(new RegisterMsg("fname2", "lname2", "email2", 'm', "uname2", "pw2"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		this.c.getCreateThread(new CreateThreadMsg("uname", "0", "something else", "new something"));
		this.c.getAddPostMsg(new AddPostMsg("uname", "0", "0", "answer to something else", "no something else"));
		this.c.getAddPostMsg(new AddPostMsg("uname", "0", "1", "another answer to something else", "no something else continues"));
		this.c.getAddPostMsg(new AddPostMsg("uname", "0", "2", "another answer to something else", "no something else continues"));
		OkMsg msg1 = (OkMsg)this.c.getRemovePostMsg(new RemovePostMsg("uname", "0", "2"));
		assertTrue(msg1.getBody().contains("post was removed successfully"));
		OkMsg msg2 = (OkMsg)this.c.getRemovePostMsg(new RemovePostMsg("Masha", "0", "1"));
		assertTrue(msg2.getBody().contains("post was removed successfully"));
		this.c.getLogoffMsg(new LogoutMsg("uname"));
		ErrorMsg err1 = (ErrorMsg)this.c.getRemovePostMsg(new RemovePostMsg("uname", "0", "0"));
		assertTrue(err1.getBody().contains("must be logged in"));
		ErrorMsg err2 = (ErrorMsg)this.c.getRemovePostMsg(new RemovePostMsg("uname1", "0", "0"));
		assertTrue(err2.getBody().contains("a suitable authority"));
		ErrorMsg err3 = (ErrorMsg)this.c.getRemovePostMsg(new RemovePostMsg("uname", "0","1"));
		assertTrue(err3.getBody().contains("Post does not exist"));
	//	ErrorMsg err4 = (ErrorMsg)this.c.getRemovePostMsg(new RemovePostMsg("uname", "0", "1"));
	//	assertTrue(err4.getBody().contains("Thread does not exist"));
		ErrorMsg err5 = (ErrorMsg)this.c.getRemovePostMsg(new RemovePostMsg("uname", "1", "1"));
		assertTrue(err5.getBody().contains("Forum does not exist"));
	}

	@Test
	public void testGetRemoveThreadMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'f', "uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		this.c.getCreateThread(new CreateThreadMsg("uname", "0", "something else", "new something"));
		this.c.getCreateThread(new CreateThreadMsg("uname1", "0", "something else1", "new something1"));
		this.c.getCreateThread(new CreateThreadMsg("uname1", "0", "something else2", "new something2"));
		OkMsg msg1 = (OkMsg)this.c.getRemoveThreadMsg(new RemoveThreadMsg("uname", "0", "0"));
		assertTrue(msg1.getBody().contains("Thread was removed successfully"));
		OkMsg msg2 = (OkMsg)this.c.getRemoveThreadMsg(new RemoveThreadMsg("Masha", "0", "1"));
		assertTrue(msg2.getBody().contains("Thread was removed successfully"));
		this.c.getLogoffMsg(new LogoutMsg("uname1"));
		ErrorMsg err1 = (ErrorMsg)this.c.getRemoveThreadMsg(new RemoveThreadMsg("uname1", "0", "2"));
		assertTrue(err1.getBody().contains("User must be logged in in order to remove thread"));
		ErrorMsg err2 = (ErrorMsg)this.c.getRemoveThreadMsg(new RemoveThreadMsg("uname", "0", "2"));
		assertTrue(err2.getBody().contains("a suitable authority"));
		ErrorMsg err3 = (ErrorMsg)this.c.getRemoveThreadMsg(new RemoveThreadMsg("uname", "0", "3"));
		assertTrue(err3.getBody().contains("Thread does not exist"));
		ErrorMsg err4 = (ErrorMsg)this.c.getRemoveThreadMsg(new RemoveThreadMsg("uname", "1", "2"));
		assertTrue(err4.getBody().contains("Forum does not exist"));
	}

	@Test
	public void testGetRemoveForumMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname","pw"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something new"));
		OkMsg msg = (OkMsg)this.c.getRemoveForumMsg(new RemoveForumMsg("Masha", "0"));
		assertTrue(msg.getBody().contains("Forum was removed successfully"));
		ErrorMsg err1 = (ErrorMsg)this.c.getRemoveForumMsg(new RemoveForumMsg("Olgasib", "1"));
		assertTrue(err1.getBody().contains("User must be logged in in order to remove forum"));
		ErrorMsg err2 = (ErrorMsg)this.c.getRemoveForumMsg(new RemoveForumMsg("uname", "1"));
		assertTrue(err2.getBody().contains("must be a moderator"));
		ErrorMsg err3 = (ErrorMsg)this.c.getRemoveForumMsg(new RemoveForumMsg("Masha", "0"));
		assertTrue(err3.getBody().contains("does not exist"));
	}

	@Test
	public void testGetForumsListMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'f', "uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something new"));
		GotListOfForumsMsg msg = (GotListOfForumsMsg)this.c.ForumsListReq(new GetListOfForumsMsg("uname"));
		assertFalse(msg.getListOfForums().isEmpty());
		ErrorMsg err = (ErrorMsg)this.c.ForumsListReq(new GetListOfForumsMsg("uname1"));
		assertTrue(err.getBody().contains("User must be logged in in order to see the list of forums"));
	}

	@Test
	public void testGetForumsTopicsMsg(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'f', "uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something new"));
		this.c.getCreateThread(new CreateThreadMsg("uname", "0", "something else", "new something"));
		this.c.getCreateThread(new CreateThreadMsg("uname1", "0", "something else1", "new something1"));
		this.c.getCreateThread(new CreateThreadMsg("uname1", "0", "something else2", "new something2"));
		OkMsg msg = (OkMsg)this.c.getForumsTopicsMsg(new GetForumTopicsMsg("uname", "0"));
		assertFalse(msg.getBody().isEmpty());
		System.out.println(msg.getBody());
		ErrorMsg err = (ErrorMsg)this.c.getForumsTopicsMsg(new GetForumTopicsMsg("uname1", "1"));
		assertTrue(err.getBody().contains("User must be logged in in order to see the list of topics of the forum"));
	}

	@Test
	public void testGetThreadOfForum(){
		this.c.getRegisterMsg(new RegisterMsg("fname", "lname", "email", 'f', "uname", "pw"));
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'f', "uname1", "pw1"));
		this.c.getRegisterMsg(new RegisterMsg("fname2", "lname2", "email2", 'f', "uname2", "pw2"));
		this.c.getLoginMsg(new LoginMsg("uname", "pw"));
		this.c.getLoginMsg(new LoginMsg("uname1", "pw1"));
		this.c.getLoginMsg(new LoginMsg("Masha", "gxyze"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something"));
		this.c.getAddForumMsg(new AddForumMsg("Masha", "something new"));
		this.c.getCreateThread(new CreateThreadMsg("uname", "0", "something else", "new something"));
		this.c.getCreateThread(new CreateThreadMsg("uname1", "0", "something else1", "new something1"));
		this.c.getCreateThread(new CreateThreadMsg("uname1", "0", "something else2", "new something2"));
		this.c.getAddPostMsg(new AddPostMsg("uname", "0", "0", "answer to something else", "no something else"));
		this.c.getAddPostMsg(new AddPostMsg("uname", "0", "1", "another answer to something else", "no something else continues"));
		this.c.getAddPostMsg(new AddPostMsg("uname", "0", "2", "another answer to something else", "no something else continues"));
		OkMsg msg = (OkMsg)this.c.getThreadOfForum(new GetThreadMsg("uname", "0", "0"));
		assertFalse(msg.getBody().isEmpty());
		System.out.println(msg.getBody());
		ErrorMsg err = (ErrorMsg)this.c.getForumsTopicsMsg(new GetForumTopicsMsg("uname2", "1"));
		assertTrue(err.getBody().contains("User must be logged in in order to see the list of topics of the forum"));
	}
	
	@Test
	public void testGetFriendsOfUser(){
		this.c.getRegisterMsg(new RegisterMsg("fname1", "lname1", "email1", 'f', "uname1", "pw1"));
		this.c.getRegisterMsg(new RegisterMsg("fname2", "lname2", "email2", 'f', "uname2", "pw2"));
		this.c.getRegisterMsg(new RegisterMsg("fname3", "lname3", "email3", 'f', "uname3", "pw3"));
		this.c.getRegisterMsg(new RegisterMsg("fname4", "lname4", "email4", 'f', "uname4", "pw4"));
		this.c.getLoginMsg(new LoginMsg("uname1", "pw1"));
		this.c.getAddUserFriendMsg(new AddFriendMsg("uname1", "uname2"));
		this.c.getAddUserFriendMsg(new AddFriendMsg("uname1", "uname3"));
		this.c.getAddUserFriendMsg(new AddFriendMsg("uname1", "uname4"));
		GotFriendsListMsg msg = (GotFriendsListMsg)this.c.getFriendsList(new GetFriendsListMsg("uname1"));
		ArrayList<String> friendsList = msg.getListOfFriends();
		assertEquals(3, friendsList.size());
		

	}

}
